let baseURL='https://'
if(process.env.NODE_ENV === 'development'){
    baseURL='https://'
}
const OPEN =`${baseURL}open.yunbisai.com`;
const API =`${baseURL}api.yunbisai.com`;
function request(method, url, data) {
		var tokens="";
		if(uni.getStorageSync("token")){
			tokens=uni.getStorageSync('token')
		}else{
			tokens=""
		}
		// switch (method){
		// 	case 'post':

		// 	case 'get':
		// 	case "put":
		// 	case "delete":
		// 		return uni.request({
		// 			method:method,
		// 			url:url,
		// 			data:data,
		// 			header: {
		// 				"token":tokens,
		// 			}
		// 		}).then(res => {
  //                   if (res[1].data.status && res[1].data.code == 200) {
  //                       return res[1]
  //                   } else {
  //                       throw res[1].data
  //                   }
  //               })
		// 	default: console.error('未知的method' + method);
		// }
        // uni.showLoading({
        //     title: '加载中'
        // });
        return new Promise((resolve,reject)=>{
            return uni.request({
                method:method,
                url:url,
                data:data,
                header: {
                    "token":tokens,
                    "content-type":"application/json"
                },
                success:(res)=> {
                    resolve(res)
                },
                fail:(err)=>{
                    reject(err.data)
                },
                complete() {
                    // uni.hideLoading()
                }
            })
        })
}
//无需token
//小程序
//获取机构账号
export const chessAccount = params => request('get', `${API}/wechat/Login`, params)
//获取token
export const receiveToken = params => request('get', `${OPEN}/wechat/Login/index`, params)
//h5
//获取机构账号
 export const chessAccount_hfive = params => request('get', `${API}/wechat/Login/getOrg`, params)
//获取token
 export const receiveToken_hfive = params => request('get', `${OPEN}/wechat/Login/index`, params)
//需要token
//授权赛事列表
export const authorizedList = params => request('get', `${API}/event/Msevent/planList`, params)
//授权赛事详情
export const authorizedDetail = params => request('get', `${API}/event/Msevent/planInfo`, params)
 //审核赛事列表
export const auditList = params => request('post', `${API}/event/Msevent/examinelist`, params)
 //审核赛事详情
export const auditDetail = params =>request('post', `${API}/event/Msevent/examinelist`,params)
 //非省级授权赛事
export const toAuthorizedEvent = params => request('get', `${API}/event/Msevent/handleEvent`,params)
 //省级授权赛事
export const toAuthorizedPlanEvent = params => request('get', `${API}/event/Msevent/handlePlanEvent`,params)
 //审核赛事
export const toAuditEvent = params => request('post', `${API}/event/Msevent/examine`,params)
 //会员段位搜索范围
export const rankExtent = params => request('post', `${API}/organization/Msorg/orgLevellist`,params)
 //会员分配
export const memberAllocation = params => request('post', `${API}/member/Msmember/allotMember`,params)
 //会员列表
export const memberList = params => request('get', `${API}/member/Msmember/getList`,params)
 //棋协费用配置
export const chessCost = params => request('get', `${API}/admin/Price/getList`,params)
//生成年费订单
export const yearOrder = params => request('post', `${API}/member/Msmember/feesOrder`,params)
 //转会记录
export const transferList = params => request('get', `${API}/member/Msmember/transferList`,params)
 //转会申请
export const transferApplication = params => request('post', `${API}/member/Msmember/updateTransfer`,params)
 //查找会员信息
export const findMember = params => request('post', `${API}/member/Msmember/findMember`,params)
//获取棋协列表
export const allocationChess = params => request('post', `${API}/organization/Msorg/getList`,params)
//上传图片
export const uploadImg = params => request('post', `${API}/admin/Upload/uploadImg`,params)
//获取会员详情
export const memCheckDetail = params => request('get', `${OPEN}/member/MsMember/memDetail`,params)
//获取会员详情
export const memDetail = params => request('get', `${API}/member/Msmemberinfo/index`,params)
//获取会员生涯
export const memCareer = params => request('get', `${OPEN}/member/MsMember/career`,params)
//审核会员
export const checkMember = params => request('post', `${OPEN}/member/MsMember/examineMem`,params)
//支付
export const pay = params => request('get', `${OPEN}/wechat/pay/index`,params)
//申请转会
export const applicationTransfer = params => request('post', `${API}/member/Msmember/transfer`,params)
//棋协统计数据
export const getMsStatistics = params => request('post', `${API}/organization/Msorg/statistics`,params)
//获取待操作数量
export const getMsNum = params => request('post', `${OPEN}/ms/index`,params)
//获取棋协信息
export const getOrgInfo = params => request('post', `${API}/organization/Msorg/index`,params)
//绑定手机
export const bindPhone = params => request('post', `${API}/organization/Msorg/upPhoneEmail`,params)
//绑定云比赛账号
export const bindYun = params => request('post', `${API}/admin/Bind/index`,params)
//发送手机验证码
export const sendMessage =  params => request('post', `${API}/sendcode/Sendcode/bindCard`, params)
//发送邮箱验证码
export const sendEmail =  params => request('post', `${API}/sendcode/Sendmail/sendmail`, params)
//注册云比赛账号
export const registerYun =  params => request('post', `${API}/admin/orgreg/index`, params)
//钱包信息
export const getWalletInfo =  params => request('get', `${API}/wallet/Mswallet/info`, params)
//银行卡列表
export const getBankList =  params => request('post', `${OPEN}/ms/bank/list`, params)
//绑定银行卡
export const bindBankCard =  params => request('post', `${API}/wallet/Mswallet/update`, params)
//棋协收支明细
export const getWalletLog =  params => request('post', `${API}/wallet/Mswalletlog/getOrgList`, params)
//修改二级密码
export const changeTraderPwd =  params => request('post', `${API}/user/Msuser/trader`, params)
//提现申请
export const withdrawal =  params => request('post', `${API}/wallet/Mswallet/withdraw`, params)
//成绩审核列表
export const getGradeList =  params => request('get', `${OPEN}/ms/grade/list`, params)
//棋协赛事详情
export const getEventDetail =  params => request('get', `${API}/event/Msevent/planInfo`, params)
//成绩审核名单 小组
export const getCertList =  params => request('get', `${API}/cert/Mscert/waitCertList`, params)
//编辑赛事选手成绩
export const updateCert =  params => request('post', `${API}/cert/Mscert/updateCert`, params)
//成绩确认审核
export const valCert =  params => request('get', `${API}/cert/Mscert/valCertList`, params)
//批量购买选手
export const applyCe =  params => request('post', `${API}/cert/Mscert/orderCert`, params)
//关闭订单
export const closeOrders =  params => request('get', `${API}/cert/Mscert/closeOrders`, params)
//获取机构名
export const getOrgNameList =  params => request('get', `${OPEN}/member/MsMember/getOrg`, params)
//棋协机构权限
export const getUserPow =  params => request('post', `${OPEN}/ms/Home/getUserPower`, params)
//获取机构名
export const getMsOrg =  params => request('get', `${OPEN}/member/MsMember/getOrg`, params)
//解绑银行卡
export const unBindBank =  params => request('post', `${OPEN}/ms/bank/untie`, params)
//获取棋协标题
export const getMSName =  params => request('get', `${OPEN}/ms/home/header`, params)
